﻿using System.Collections.Generic;
using System.Linq;
using DataBaseLayer.Dto;
using Peresvet.Models;

namespace Peresvet.Extensions
{
	public static class GalleryItemModelEx
	{
		public static GalleryItemModel ConvertGalleryDataItemToMVCModel(this GalleryData data)
		{
			if (data == null) return null;

			return new GalleryItemModel
			{
				Date = data.Date,
				GalleryId = data.GalleryId,
				ImageUrl = data.ImageUrl,
				ThumbImageUrl = data.ThumbImageUrl,
				Images = data.Images,
				Name = data.Name
			};
		}

		public static IEnumerable<GalleryItemModel> ConvertGalleryDataItemsToMVCModel(this IEnumerable<GalleryData> data)
		{
			if (data == null && data.Any()) return null;

			return data.Select(item => item.ConvertGalleryDataItemToMVCModel()).ToList();
		}
	}
}